using DimensionsHelper.Common.Utils;
using DimensionsHelper.LanguageService.Symbols;
using DimensionsHelper.LanguageService.Syntax;

namespace DimensionsHelper.LanguageService;

public class AnalysisEnumSignature : AnalysisStatementWithDomain
{
    internal AnalysisEnumSignature(
        EnumSignature enumSignature,
        EnumSymbol enumSymbol,
        AnalysisNode? parent) :
        base(AnalysisBoundKinds.EnumSignature, enumSignature, enumSymbol, parent)
    {
        Syntax = enumSignature;
        enumSignature.Members.ForEach(e =>
        {
            AnalysisEnumMemberSignature id = AnalysisNodeFactory.EnumMemberSignature(e, this);
            Children.Add(id);
        });
    }

    public override EnumSignature Syntax { get; }

    public override AnalysisBlock? Body => null;
}


public static partial class AnalysisNodeFactory
{
    /// <summary>
    ///   创建一个枚举声明的分析节点
    /// </summary>
    /// <param name="syntaxNode">原始语法节点</param>
    /// <param name="enumSymbol">类型符号</param>
    /// <param name="parent">父节点，可以忽略</param>
    public static AnalysisEnumSignature EnumSignature(
        EnumSignature syntaxNode,
        EnumSymbol enumSymbol,
        AnalysisNode? parent)
    {
        return new AnalysisEnumSignature(syntaxNode, enumSymbol, parent);
    }
}